package com.edou.cms.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.cms.dao.ICmsColumnBlogDao;
import com.edou.cms.entity.CmsColumnBlog;
import com.edou.cms.service.ICmsColumnBlogService;

import com.edou.cms.dto.CmsColumnBlogCondition;

@Service("cmsColumnBlogServiceImpl")
@Transactional(value = "transactionManager")
public class CmsColumnBlogServiceImpl implements ICmsColumnBlogService{

	@Resource(name = "cmsColumnBlogDaoImpl")
	private ICmsColumnBlogDao cmsColumnBlogDao;

	/**
	 * 分页查询
	 * @param pageResult 分页对象
	 * @param condition 查询条件类
	 */
	public void listCmsColumnBlogByPage(PageResult<CmsColumnBlog> pageResult,CmsColumnBlogCondition condition){
		int rows = cmsColumnBlogDao.listCmsColumnBlogByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<CmsColumnBlog> list = cmsColumnBlogDao.listCmsColumnBlogByPage(rowBounds,condition);
		pageResult.setResult(list);
	}

	/**
	 * 根据ID查询
	 * @param id 主键
	 * @return 专栏内的推荐博主
	 */
	public CmsColumnBlog getCmsColumnBlogById(String id){
		return cmsColumnBlogDao.getCmsColumnBlogById(id);
	}

	/**
	 * 新增
	 * @param item 专栏内的推荐博主
	 */
	public void add(CmsColumnBlog item){
		cmsColumnBlogDao.add(item);
	}

	/**
	 * 修改
	 * @param item 专栏内的推荐博主
	 */
	public void update(CmsColumnBlog item){
		cmsColumnBlogDao.update(item);
	}

	/**
	 * 根据ID集合批量删除
	 * @param ids ID集合
	 */
	public void delByIds(String[] ids){
		cmsColumnBlogDao.delByIds(ids);
	}

}

